package org.jeecg.basic.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.basic.entity.MesBomHeaderSetup;
import org.jeecg.basic.mapper.MesBomHeaderSetupMapper;
import org.jeecg.basic.mapper.MesBomItemSetupMapper;
import org.jeecg.basic.service.IMesBomHeaderSetupService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @Description: 产品主数据
 * @Author: LiCY
 * @Date: 2023-06-16
 * @Version: V1.0
 */
@Service
public class MesBomHeaderSetupServiceImpl extends ServiceImpl<MesBomHeaderSetupMapper, MesBomHeaderSetup> implements IMesBomHeaderSetupService {

    @Autowired
    private MesBomHeaderSetupMapper mesBomHeaderSetupMapper;
    @Autowired
    private MesBomItemSetupMapper mesBomItemSetupMapper;

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void delMain(String id) {
        mesBomItemSetupMapper.deleteByMainId(id);
        mesBomHeaderSetupMapper.deleteById(id);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void delBatchMain(List<MesBomHeaderSetup> list) {
        for (MesBomHeaderSetup item : list) {
            mesBomItemSetupMapper.deleteByMainId(item.getPartno());
            this.removeById(item);
        }
    }

}
